package com.scheduling.schedule.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.scheduling.schedule.entity.ScheduleDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 排产详情Mapper接口
 *
 * @author 开发团队
 */
@Mapper
public interface ScheduleDetailMapper extends BaseMapper<ScheduleDetail> {

    /**
     * 根据排产计划ID查询详情
     *
     * @param planId 排产计划ID
     * @return 排产详情列表
     */
    @Select("SELECT * FROM schedule_detail WHERE plan_id = #{planId} ORDER BY sequence_no ASC")
    List<ScheduleDetail> selectByPlanId(@Param("planId") String planId);

    /**
     * 根据机器ID查询排产详情
     *
     * @param machineId 机器ID
     * @return 排产详情列表
     */
    @Select("SELECT * FROM schedule_detail WHERE machine_id = #{machineId} ORDER BY scheduled_start_time ASC")
    List<ScheduleDetail> selectByMachineId(@Param("machineId") String machineId);

    /**
     * 根据任务ID查询排产详情
     *
     * @param taskId 任务ID
     * @return 排产详情
     */
    @Select("SELECT * FROM schedule_detail WHERE task_id = #{taskId}")
    ScheduleDetail selectByTaskId(@Param("taskId") String taskId);
} 